package com.liuzh.deviceinfo.view.togglebuttongroup;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Checkable;
import com.liuzh.deviceinfo.view.togglebuttongroup.button.MarkerButton;

public class SingleSelectToggleGroup extends ToggleButtonGroup {
    public a p;
    public int q = -1;

    public interface a {
    }

    public SingleSelectToggleGroup(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    private void setCheckedId(int i) {
        h(i, true);
    }

    public void addView(View view, int i, LayoutParams layoutParams) {
        if (view instanceof Checkable) {
            if (((Checkable) view).isChecked()) {
                int i2 = this.q;
                if (i2 != -1) {
                    g(i2, false);
                }
                if (view.getId() == -1) {
                    view.setId(ViewGroup.generateViewId());
                }
                setCheckedId(view.getId());
            }
            if (view instanceof MarkerButton) {
                ((MarkerButton) view).setRadioStyle(true);
            }
        }
        super.addView(view, i, layoutParams);
    }

    public <T extends View & Checkable> void f(T t, boolean z) {
        if (z) {
            int i = this.q;
            if (!(i == -1 || i == t.getId())) {
                g(this.q, false);
            }
            int id = t.getId();
            if (this.k == id) {
                this.k = -1;
                h(id, false);
                return;
            }
            setCheckedId(id);
        }
    }

    public int getCheckedId() {
        return this.q;
    }

    /* JADX WARNING: No exception handlers in catch block: Catch:{  } */
    public final void h(int r7, boolean r8) {
        /*
        r6 = this;
        r6.q = r7;
        if (r8 == 0) goto L_0x0079;
    L_0x0004:
        r7 = r6.p;
        if (r7 == 0) goto L_0x0079;
    L_0x0008:
        r7 = (c.h.a.j0.h) r7;
        r7 = r7.a;
        java.util.Objects.requireNonNull(r7);
        r8 = r6.getCheckedId();
        r8 = r6.findViewById(r8);
        r8 = (c.h.a.n0.g) r8;
        r0 = r7.b0;
        r0.clear();
        r0 = r7.m0();
        if (r0 == 0) goto L_0x0025;
    L_0x0024:
        goto L_0x0079;
    L_0x0025:
        r8 = r8.getCameraId();
        r8 = java.lang.String.valueOf(r8);
        r0 = r7.b0;
        r1 = r7.c0;	 Catch:{ CameraAccessException -> 0x0072 }
        r8 = r1.getCameraCharacteristics(r8);	 Catch:{ CameraAccessException -> 0x0072 }
        r0.clear();
        r1 = r8.getKeys();	 Catch:{  }
        r1 = r1.iterator();
    L_0x0040:
        r2 = r1.hasNext();
        if (r2 == 0) goto L_0x0072;
    L_0x0046:
        r2 = r1.next();
        r2 = (android.hardware.camera2.CameraCharacteristics.Key) r2;
        r3 = r7.m0();
        if (r3 == 0) goto L_0x0053;
    L_0x0052:
        goto L_0x0072;
    L_0x0053:
        r3 = c.h.a.m0.k.m(r2, r8);
        r4 = android.text.TextUtils.isEmpty(r3);
        if (r4 != 0) goto L_0x0040;
    L_0x005d:
        r4 = new c.h.a.d0.b;
        r2 = r2.getName();
        r5 = r7.k();
        r2 = c.h.a.m0.k.y(r2, r5);
        r4.m1953init(r2, r3);
        r0.add(r4);
        goto L_0x0040;
    L_0x0072:
        r7 = r7.Z;
        r7 = r7.a;
        r7.b();
    L_0x0079:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.liuzh.deviceinfo.view.togglebuttongroup.SingleSelectToggleGroup.h(int, boolean):void");
    }

    public void onFinishInflate() {
        super.onFinishInflate();
        int i = this.j;
        if (i == -1) {
            i = this.k;
        }
        if (i != -1) {
            g(i, true);
            h(i, false);
        }
    }

    public void setOnCheckedChangeListener(a aVar) {
        this.p = aVar;
    }
}
